import Layouts from "@/layouts";
import Index from "@/pages";
import { createHashRouter, RouterProvider } from "react-router-dom";
import NotFound from "../pages/404";
import Home from "../pages/home/index";
import Login from "../pages/login/index";
import Test from "../pages/test/index";

// 2. 创建路由实例
const router = createHashRouter(
  [
    {
      path: "/",
      element: <Index />,
    },
    {
      path: "/login",
      element: <Login />,
    },
    {
      path: "/my-blog",
      element: <Layouts />,
      children: [
        {
          path: "/my-blog",
          element: <Home />,
        },
        {
          path: "/my-blog/test",
          element: <Test />,
        },
      ],
    },
    {
      path: "*",
      element: <NotFound />,
    },
  ],
  { basename: "/" },
);

const RouterProviderRoot = () => {
  return <RouterProvider router={router} />;
};

export default RouterProviderRoot;
